﻿using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Text;

namespace ZhongJia.Lock.Infrastructure
{
    public class UserFriendlyException : Exception
    {
        public int Code { get; set; }

        public string Key { get; set; }

        public LogLevel Severity { get; set; }

        public UserFriendlyException()
        {
            Severity = LogLevel.Warning;
        }

        public UserFriendlyException(string message) : base(message)
        {
            Code = 200;
        }

        public UserFriendlyException(string key, string message)
          : base(message)
        {
            Code = 200;
            Key = key;
            Severity = LogLevel.Warning;
        }

        public UserFriendlyException(string message, LogLevel severity)
          : base(message)
        {
            Code = 200;
            Severity = severity;
        }

        public UserFriendlyException(int code, string message)
          : base(message)
        {
            Code = code;
        }

        public UserFriendlyException(string message, Exception innerException)
           : base(message, innerException)
        {
            Severity = LogLevel.Warning;
        }
    }
}
